# -*- coding: utf-8 -*-

from odoo import fields, api
from odoo_contrib import models as contrib_models


class ExhibitFavourites(contrib_models.SchemaModel):
    _name = 'exhibition.exhibit_favourites'
    _description = 'Wechat User favourites exhibits'
    _order = 'create_date desc'

    exhibit = fields.Many2one(
        'exhibition.exhibit',
        required=True,
        ondelete='cascade',
    )
    wechat_user = fields.Many2one(
        'wechat.user',
        required=True,
        ondelete='cascade',
    )

    _sql_constraints = [
        ('uq_exhibit_wechat_user', 'UNIQUE(exhibit, wechat_user)', 'Already added to your favourites'),
    ]
